<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"          
<"http://www.w3.org/TR/html4/strict.dtd">
<html lang=â€�pt-brâ€�>
<head>
<?php

	error_reporting('E_NONE');
	ini_set('display_errors',1); 
	include_once "includes/funcoes.php";
	include_once "mecanismos/conecta.php";
	include_once "includes/constantes.php";
	include_once "classes/classePadrao.php";

	p($_REQUEST);
	/*foreach($_POST as $key=>$value)
	{
		$_POST[$key]=anti_sql_injection($value);
	}
	
	foreach($_GET as $key=>$value)
	{
		$_GET[$key]=anti_sql_injection($value);
	}*/
	
	if($_POST["enviouDados1"])
	{
		require_once "classes/classeUsuario.php";
	
		$objUsuario = new classeUsuario($conexao);
	
  		$autenticacao=0;	

	 	$login = trim(str_replace("'", "", $_POST["login"]));
	  	$senha = (trim(str_replace("'", "", $_POST["senha"])));
	
	 	$autenticacao = $objUsuario->logarUsuario($login, $senha);

		if($autenticacao["SUCESSO"]==1)
	  	{
	  		if($autenticacao["TIPO"]==1)
	  	  	{
	  	  		$_SESSION["CLIENTE"]["ID_USUARIO"]  = $autenticacao["ID_USUARIO"];
			    $_SESSION["CLIENTE"]["NOME"]  = $autenticacao["NOME"];
	  	  		header("Location:?pg=areaUserCliente.php");
	  	  	}
	  	  	else
	  	  	{
		  	  	if($autenticacao["TIPO"]==0)
		  	  	{
		  	  		$_SESSION["ANUNCIANTE"]["ID_USUARIO"]  = $autenticacao["ID_USUARIO"];
				    $_SESSION["ANUNCIANTE"]["NOME"]  = $autenticacao["NOME"];
		  	  		header("Location:?pg=areaUserAnunciante.php");
		  	  	}
		  	  	else
		  	  	{
		  	  		echo '<script>alert("Problemas ao criar area")</script>';
		  	  	}
	  	  	}
		  } 
		  else
		  {
	      	 $msg=$autenticacao["MSG"];
	     
		     if($autenticacao["SUCESSO"]==0)//senha incorreta
		     {
		     	$objUsuario->login=$_POST["login"];
		     	$arrayUsuarios=$objUsuario->buscarUsuario();
		     }
		  }
	}
	
	if($_POST["pesquisa"])
	{
		require_once "classes/classeAnuncio.php";
		$objAnuncio = new classeAnuncio($sConexao);
		
		$objAnuncio->tipo = $_POST["tipo"];
		$objAnuncio->zona = $_POST["zona"];
		$arrayAnuncios = $objAnuncio->buscarAnuncio();
	}
?>
<head>
<title>SafeBusca</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="menu_assets/styles.css" rel="stylesheet" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css"/>
<script src="Scripts/jquery/jquery-1.8.3.js" type="text/javascript"></script>
<script src="Scripts/jquery/jquery.cycle.all.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function() {

	$('#slider').cycle({
		fx:'fade'
		//cleartype:true,cleartypeNoBg: true,
	});

	<?php
	if($_GET["gu"]>=2)
	{
	?>
		$("iframe").remove();
	<?php
	} 
	?>
});

</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="body">
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div style="height: 180px; width: 100%; position:absolute; overflow: auto; background: url('img/bg_base.jpg'); background-repeat:repeat-x; float: left; z-index: -999"></div>
<div align="center" style="margin: 0 auto; width: 1024px;">
	<div align="left" style="width: 30%; float: left; margin-left: 120px;">
	<h1 class="SafebuscaM">SafeBusca.com</h1>
	<h1 class="Safebusca">SafeBusca.com</h1>
	</div>
	<div align="right" style="width: 50%; float: left; height: 107px">
	<?php 
	if(!isset($_SESSION["CLIENTE"]) && !isset($_SESSION["ANUNCIANTE"]))
	{
		?>
		 <form name="f1" action="index.php" method="post" onSubmit="return validar();" >
		 <br>
		    <input name="enviouDados1" type="hidden" value="1" />
			<a class="fontBranca">Login</a>
			<input name="login" class="input">
			<br>
			<a class="fontBranca">Senha</a>
			<input name="senha" type="password" class="input">
			<br>
			<input class="botao" type="submit" value="Entrar" style="width: 50px; margin-top: 2px; margin-right: 7px">
		</form>
		<div style="margin-top: -10px">
		<label class="fontBranca">ou  </label><a href="?pg=cadastroUser.php" class="fontBranca">cadastrar-se</a>
		</div>
		<?php 
	}
	else 
	{
		if(isset($_SESSION["CLIENTE"]))
		{
			$area="?pg=areaUserCliente.php";
		}
		else
		{
			if(isset($_SESSION["ANUNCIANTE"]))
			{
				$area="?pg=areaUserAnunciante.php";
			}
		}
		?>
		<br>
		<label class="fontBranca" style="font-weight: bold">Bem vindo:</label><label class="fontBranca"> <?php echo primeiroNome($_SESSION["CLIENTE"]["NOME"]) ;?></label>
		<a class="fontBranca" href="<?php echo $area ?>">Area Privada</a><label class="fontBranca"> | </label><a class="fontBranca" href="logout.php">sair</a>
		<?php
	}
	?>
	</div>
	<?php include"menuHorizontal.php"; ?>
<div style="height: 344px; width: 90%; position: relative; overflow: auto;">
	<div class="bordaImagem" id="slider" style="height: 340px; width: 66%; float: left;">
	<?php
	$path="img/topo/";
	
	// abre o diretório
	   if($ponteiro  = opendir($path))
	   {
	// monta os vetores com os itens encontrados na pasta
		while ($nome_itens = readdir($ponteiro)) {
		    $itens[] = $nome_itens;
		}
		  $style2="";
		  foreach ( $itens as $key => $value)
		  {
	  		if(ereg("[0-9]{1,}[.jpg]{1}",$value))
	  		{
	  			$imagem=$path.$value;
	  			echo '<div style="'.$style2.'">
		  			  	<img height="340" width="608" src="'.$imagem.'" alt="">
		  			  </div>';
	  			$style2="display:none";
	  		}
		  }
	   }
	
	?>	 
	</div>
	<div align="center" class="quadro" style="height: 172px; width: 32%; margin-left: 10px; float: left;">
	<div class="div-titulo-caixa">
		<h3 class="titulo-caixa">Pesquisar</h3>
	</div>
		<div align="left" style="margin-top: -8px; background-color: #FFFFFF">
			<div style="padding: 10px">
				<form name="pesquisa" action="index.php" method="post" onSubmit="return validarPesquisa();" >
				<input name="pesquisa" type="hidden" value="1" />
					<a>Tipo :</a>
					<select name="tipo" style="width: 10em">
						<?php foreach ($arrayTipos as $tipo)
						{
							echo '<option value="'.$tipo.'">'.$tipo.'</option>';
						}
						?>
					</select>
					<br>
					<a>Zona:</a>
					<select name="zona" style="width: 10em">
						<?php foreach ($arrayZonas as $zona)
						{
							echo '<option value="'.$zona.'">'.$zona.'</option>';
						}
						?>
					</select>
					<br>
					<a>Valor</a>
					<span>De:</span> <input name="valor_ini" size="10"> <span>Ate:</span> <input name="valor_fim" size="10">
					<br>
					<input class="botao" type="submit" value="Buscar" style="width: 60px">
				</form>
			</div>
		</div>
	</div>
	<div class="quadro" style="height:156px; width: 295px; margin-left: 10px; margin-top: 8px; float: left;">
	<div class="fb-like-box" data-href="http://www.facebook.com/SafeBusca" data-width="293" data-height="154" data-show-faces="true" data-stream="false" data-header="true"></div>
	</div>
</div>

<div align="center" class="quadro" style="height: 160px; width: 90%; margin-top: 10px">
	<div style="float: left; cursor: pointer;"><img src="img/seta-e.jpg" height="160px"></div>
	<div style="float: right; cursor: pointer;"><img src="img/seta-d.jpg" height="160px"></div>
</div>
<div align="center" class="quadro" style="height:600; width: 90%; margin-top: 10px;">
<?php      
 	/**  miolo **/ 
	$pg=$_GET["pg"];
	//include ($pg);
	/*echo "PG";
	echo $pg;
	echo "-x-";
	//echo phpinfo();
	include ($pg);
	*/

	$pg=isset($_GET["pg"])?$_GET["pg"]:"home.php";
	$pg=addslashes($pg);
	
	//Verifica se a string passada possui algum trecho inv&aacute;lido
    //Caso tenha mostra uma mensagem de erro
    if(eregi("http|www|ftp|.dat|.txt|.gif|wget| |.asp|/|\\\\", $pg))
    {
        //include("home.php");
        echo "<script type=\"text/Javascript\">";
        echo "location='index.php'";
        echo "</script>";
        return;
    //Se a vari&aacute;vel passada estiver dentro das normas, executa o else abaixo
    }else{
        if(!empty($pg) && file_exists($pg)) {
            @include ($pg);
        }else{
            @include ("home.php"); //essa seria a sua p&aacute;gina principal
			echo"falha no else ", $pg;
        }
    }
?>
</div>
</div>
<div style="height:60px; width: 100%; position:absolute; overflow: auto; background: url('img/rodape.jpg'); background-repeat:repeat-x; float: left; z-index: -999; margin-top: 20px">
	<div style="margin-top: 10px; text-align: center">
		<a class="fontBranca">Email: sac@mbusca.com.br</a><br>
		<a class="fontBranca">Fones: (92)8832-6144 / (92)9371-1782  </a>
	</div>
</div>
</body>
</html>